package engine

import (
    "github.com/rthornton128/goncurses"
)

type Key goncurses.Key
const (
    KEY_TAB       Key = Key(goncurses.KEY_TAB)
    KEY_RETURN        = goncurses.KEY_RETURN
    KEY_ESC           = goncurses.KEY_ENTER
    KEY_DOWN          = goncurses.KEY_DOWN
    KEY_UP            = goncurses.KEY_UP
    KEY_LEFT          = goncurses.KEY_LEFT
    KEY_RIGHT         = goncurses.KEY_RIGHT
    KEY_HOME          = goncurses.KEY_HOME
    KEY_BACKSPACE     = goncurses.KEY_BACKSPACE
    KEY_F1            = goncurses.KEY_F1
    KEY_F2            = goncurses.KEY_F2
    KEY_F3            = goncurses.KEY_F3
    KEY_F4            = goncurses.KEY_F4
    KEY_F5            = goncurses.KEY_F5
    KEY_F6            = goncurses.KEY_F6
    KEY_F7            = goncurses.KEY_F7
    KEY_F8            = goncurses.KEY_F8
    KEY_F9            = goncurses.KEY_F9
    KEY_F10           = goncurses.KEY_F10
    KEY_F11           = goncurses.KEY_F11
    KEY_F12           = goncurses.KEY_F12
    KEY_DL            = goncurses.KEY_DL
    KEY_IL            = goncurses.KEY_IL
    KEY_DC            = goncurses.KEY_DC
    KEY_IC            = goncurses.KEY_IC
    KEY_EIC           = goncurses.KEY_EIC
    KEY_CLEAR         = goncurses.KEY_CLEAR
    KEY_EOS           = goncurses.KEY_EOS
    KEY_EOL           = goncurses.KEY_EOL
    KEY_SF            = goncurses.KEY_SF
    KEY_SR            = goncurses.KEY_SR
    KEY_PAGEDOWN      = goncurses.KEY_PAGEDOWN
    KEY_PAGEUP        = goncurses.KEY_PAGEUP
    KEY_STAB          = goncurses.KEY_STAB
    KEY_CTAB          = goncurses.KEY_CTAB
    KEY_CATAB         = goncurses.KEY_CATAB
    KEY_ENTER         = goncurses.KEY_ENTER
    KEY_PRINT         = goncurses.KEY_PRINT
    KEY_LL            = goncurses.KEY_LL
    KEY_A1            = goncurses.KEY_A1
    KEY_A3            = goncurses.KEY_A3
    KEY_B2            = goncurses.KEY_B2
    KEY_C1            = goncurses.KEY_C1
    KEY_C3            = goncurses.KEY_C3
    KEY_BTAB          = goncurses.KEY_BTAB
    KEY_BEG           = goncurses.KEY_BEG
    KEY_CANCEL        = goncurses.KEY_CANCEL
    KEY_CLOSE         = goncurses.KEY_CLOSE
    KEY_COMMAND       = goncurses.KEY_COMMAND
    KEY_COPY          = goncurses.KEY_COPY
    KEY_CREATE        = goncurses.KEY_CREATE
    KEY_END           = goncurses.KEY_END
    KEY_EXIT          = goncurses.KEY_EXIT
    KEY_FIND          = goncurses.KEY_FIND
    KEY_HELP          = goncurses.KEY_HELP
    KEY_MARK          = goncurses.KEY_MARK
    KEY_MESSAGE       = goncurses.KEY_MESSAGE
    KEY_MOVE          = goncurses.KEY_MOVE
    KEY_NEXT          = goncurses.KEY_NEXT
    KEY_OPEN          = goncurses.KEY_OPEN
    KEY_OPTIONS       = goncurses.KEY_OPTIONS
    KEY_PREVIOUS      = goncurses.KEY_PREVIOUS
    KEY_REDO          = goncurses.KEY_REDO
    KEY_REFERENCE     = goncurses.KEY_REFERENCE
    KEY_REFRESH       = goncurses.KEY_REFRESH
    KEY_REPLACE       = goncurses.KEY_REPLACE
    KEY_RESTART       = goncurses.KEY_RESTART
    KEY_RESUME        = goncurses.KEY_RESUME
    KEY_SAVE          = goncurses.KEY_SAVE
    KEY_SBEG          = goncurses.KEY_SBEG
    KEY_SCANCEL       = goncurses.KEY_SCANCEL
    KEY_SCOMMAND      = goncurses.KEY_SCOMMAND
    KEY_SCOPY         = goncurses.KEY_SCOPY
    KEY_SCREATE       = goncurses.KEY_SCREATE
    KEY_SDC           = goncurses.KEY_SDC
    KEY_SDL           = goncurses.KEY_SDL
    KEY_SELECT        = goncurses.KEY_SELECT
    KEY_SEND          = goncurses.KEY_SEND
    KEY_SEOL          = goncurses.KEY_SEOL
    KEY_SEXIT         = goncurses.KEY_SEXIT
    KEY_SFIND         = goncurses.KEY_SFIND
    KEY_SHELP         = goncurses.KEY_SHELP
    KEY_SHOME         = goncurses.KEY_SHOME
    KEY_SIC           = goncurses.KEY_SIC
    KEY_SLEFT         = goncurses.KEY_SLEFT
    KEY_SMESSAGE      = goncurses.KEY_SMESSAGE
    KEY_SMOVE         = goncurses.KEY_SMOVE
    KEY_SNEXT         = goncurses.KEY_SNEXT
    KEY_SOPTIONS      = goncurses.KEY_SOPTIONS
    KEY_SPREVIOUS     = goncurses.KEY_SPREVIOUS
    KEY_SPRINT        = goncurses.KEY_SPRINT
    KEY_SREDO         = goncurses.KEY_SREDO
    KEY_SREPLACE      = goncurses.KEY_SREPLACE
    KEY_SRIGHT        = goncurses.KEY_SRIGHT
    KEY_SRSUME        = goncurses.KEY_SRSUME
    KEY_SSAVE         = goncurses.KEY_SSAVE
    KEY_SSUSPEND      = goncurses.KEY_SSUSPEND
    KEY_SUNDO         = goncurses.KEY_SUNDO
    KEY_SUSPEND       = goncurses.KEY_SUSPEND
    KEY_UNDO          = goncurses.KEY_UNDO
    KEY_MOUSE         = goncurses.KEY_MOUSE
    KEY_RESIZE        = goncurses.KEY_RESIZE
    KEY_MAX           = goncurses.KEY_MAX
)

func (g *Game) RegisterKeyboardListner(listner func(*Game, Key)) {
    g.Screen.window.Timeout(0)
    go func() {
        for g.Running {
            char := g.Screen.window.GetChar()
            listner(g, Key(char))
        }
    }()
}
